package com.itbour.service.trade.impl;

import java.util.List;
import java.util.Map;

import com.itbour.com.page.JspPage;
import com.itbour.com.page.Page;
import com.itbour.dao.trade.OrderStateHisInfoDao;
import com.itbour.dto.trade.OrderStateHisDto;
import com.itbour.service.trade.OrderStateHisInfoService;

public class OrderStateHisInfoServiceImpl implements OrderStateHisInfoService{
	
	private OrderStateHisInfoDao orderStateHisInfoDao;
	
	
	public Page pageOrderStateHisInfo(Map<String, Object> parm, Integer pageNo,
			Integer pageSize) {
		try {
			Page result = null;
			int skipResults = JspPage.getStartOfPage(pageNo, pageSize);
			int totalSize = orderStateHisInfoDao.getOrderStateHisCnt(parm);
			while(totalSize >0 && totalSize <= skipResults){
				skipResults= skipResults - pageSize;
				pageNo = pageNo -1;
			}
			parm.put("pageSize", pageSize);
			parm.put("skipResults", skipResults);
			List<OrderStateHisDto> data = orderStateHisInfoDao.getOrderStateHisInfo(parm);
			result = new JspPage(skipResults, totalSize, pageSize, data);
			return result;
		} finally {
		}
	}


	public OrderStateHisInfoDao getOrderStateHisInfoDao() {
		return orderStateHisInfoDao;
	}
	public void setOrderStateHisInfoDao(OrderStateHisInfoDao orderStateHisInfoDao) {
		this.orderStateHisInfoDao = orderStateHisInfoDao;
	}
}
